<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model backend\models\Role */
/* @var $form ActiveForm */
$form = ActiveForm::begin();
?>
<style class="text/css">
	.a{
		height:50px ;
	}
</style>
 <div>管理员管理-->分配角色权限</div>
 <div class="contenttitle2">
        <h3>分配角色权限</h3>
</div>
 <center>
	<table>
		<tr class="a">
			<td>角色名称：</td>
			<td><?= $form->field($model,'role_name')->textInput(['style'=>'width:200px'])->label('') ?></td>
		</tr>
		<tr class="a">
			<td>是否启用：</td>
			<td><?= $form->field($model,'role_status')->radioList(['1'=>'启用','0'=>'不启用'])->label('') ?></td>
		</tr>
		<tr height='80px'>
			<td text-align='center'>角色描述：</td>
			<td><?= $form->field($model,'role_desc')->textArea([])->label('') ?></td>
		</tr>
		<tr>
			<td>分配权限</td>
			<td><table>
			<tbody id='tbody'>
			<?php foreach ($data as $key => $val) {
				# code...
			?><tr>
					<td width="100px"><input type="checkbox"  class="parent" name="node_id[]" value="<?= $val['node_id'] ?>" style='opacity: 0.5;'>&nbsp<?= $val['node_name'] ?></td>
					<td><?php foreach ($val['child'] as $k => $v) {?>
						<input type="checkbox"  class="son" name="node_id[]" value="<?=$v['node_id']; ?>" style='opacity: 0.5;'>&nbsp<?= $v['node_name'] ?>
					<?php } ?></td>
				</tr>
			<?php } ?>
			</tbody>
			</table></td>
		</tr>
	
    	<tr>
			<td><input type="checkbox" name="quan" style='opacity: 0.5;'>     <span>全选/全不选</span></td>
			<td></td>
		</tr>
		<tr>
		<td colspan="2" align='center'><div class="form-group">
    <div class="col-lg-offset-1 col-lg-11">
        <?= Html::submitButton('添加', ['class' => 'btn btn-primary','style'=>'border-radius:10px;width:100px;','cursor'=>'pointer']) ?>
    </div>
</div></td>
			<td></td>
		</tr>
	</table>
 <p></p>
 <p></p>
<?php ActiveForm::end() ?>
    </center>
<script src="js/plugins/jquery-1.7.min.js">
	
</script>
    <script>
    $('input[name=quan]').click(function(){
    		$('input[type=checkbox]').prop('checked',$(this).prop('checked'));
   		
    	})
    	$(".parent").click(function(){
   			$(this).parent().parent().find('.son').prop('checked',$(this).prop('checked'));
   		});
   		$(".son").click(function(){
   			if($(this).parent().find(':checked').size()==0)
	   		{
	   			$(this).parent().prev().find('.parent').prop('checked',false);
	   		}else
	   		{
	   			$(this).parent().prev().find('.parent').prop('checked',true);
	   		}
   		})
  </script>
